export default {
  namespaced: true, //命名空间
  state: {
    PanesData: [
      {
        title: "通知",
        key: "0",
        closable: false, //是否可关闭
        type: "apple", //图标
        component: "notice", //渲染组件
      },
      {
        title: "班级统计",
        key: "1",
        closable: false, //是否可关闭
        type: "apple", //图标
        component: "ranking", //渲染组件
      },
      {
        title: "发布测试",
        key: "2",
        closable: false, //是否可关闭
        type: "apple", //图标
        component: "releaseTest", //渲染组件
      },
    ],
    PanesActiveKey: "0",
    isTestPage: false,
    //新建测试数据
    CreatetopicData: [],
    CreateTitle: "",

    //编辑测试的数据
    EditTopicData: [],
    //编辑测试的id
    EditTopicId: "",
    //编辑测试的title
    EditTitle: "",
  },
  getters: {},
  mutations: {
    setPanesActiveKey(state, data) {
      state.PanesActiveKey = data;
    },
    addCreatePanesData(state) {
      state.PanesData.push({
        title: "创建测试",
        key: state.PanesData.length.toString(),
        closable: true, //是否可关闭
        type: "apple", //图标
        component: "createTest",
      });
      //   state.testKey = data.key; //选择的测试id
      state.isTestPage = true;
      state.PanesActiveKey = `${state.PanesData.length - 1}`;
    },
    editCreatePanesData(state) {
      state.PanesData.push({
        title: "编辑测试",
        key: state.PanesData.length.toString(),
        closable: true, //是否可关闭
        type: "apple", //图标
        component: "editTest",
      });
      //   state.testKey = data.key; //选择的测试id
      state.isTestPage = true;
      state.PanesActiveKey = `${state.PanesData.length - 1}`;
    },
    //退出测试
    removePandesData(state) {
      state.PanesData = state.PanesData.slice(0, -1);
      state.PanesActiveKey = "2"; //对应的测试导航页key
      state.isTestPage = false;
    },
    //设置新增测试的title
    setCreateTitle(state, data) {
      state.CreateTitle = data;
    },
    //新增测试
    addCreatetopicData(state, data) {
      state.CreatetopicData.push(data);
    },
    //修改测试
    editCreatetopicData(state, data) {
      state.CreatetopicData[data.index] = data.textContent;
    },
    //删除
    removeCreatetopicData(state, data) {
      state.CreatetopicData.splice(data, 1);
    },

    //设置修改测试的title
    setEditTopicTitle(state, data) {
      state.EditTitle = data;
    },
    //设置修改测试的data
    setEditTopicData(state, data) {
      state.EditTopicData = data;
    },
    //设置修改测试的id
    setEditTopicId(state, data) {
      state.EditTopicId = data;
    },
    //新增测试
    addEdittopicData(state, data) {
      state.EditTopicData.push(data);
    },
    //修改测试
    editEdittopicData(state, data) {
      state.EditTopicData[data.index] = data.textContent;
    },
    //删除
    removeEdittopicData(state, data) {
      state.EditTopicData.splice(data, 1);
    },
  },
  actions: {},
  modules: {},
};
